<?php
/*
* Tool Name: Free BaZhan Tool
* My URI: https://ba.aa1.cn/
* Author: 夏柔
* Author URI: https://www.aa1.cn/
* Description: 免费扒站单页系统
* Version: 1.0.0
* Requires PHP: 5.0～8.0
*/
// 获取Get方法请求的
$urlget = $_GET["url"] ;
// 获取url
$url2 = $_POST["burl"]?:$urlget;
// 判断是否有远程资源文件
$urlbg = 'https://bz.v.api.aa1.cn/down/'.$url2.'.zip';
//获取当前网页url
$baurl = $_SERVER['HTTP_HOST'];
// 判断是否扒过了
$get1=get_headers($urlbg);
$statusCode=substr($get1[0], 9, 3);
if($statusCode == 200 || $statusCode == 304 || $statusCode == 301){
    $downloadurl = $urlbg;
    $msg = '已扒取成功';
    echo '<div id="note-43044f05" class="notification" style="transform: translateY(200%);"><div class="notification__box"><div class="notification__content"><div class="notification__icon"><svg t="1668006927559" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2695" width="32" height="32"><path d="M512 85.333333c235.648 0 426.666667 191.018667 426.666667 426.666667s-191.018667 426.666667-426.666667 426.666667S85.333333 747.648 85.333333 512 276.352 85.333333 512 85.333333z m-74.965333 550.4L346.453333 545.152a42.666667 42.666667 0 1 0-60.330666 60.330667l120.704 120.704a42.666667 42.666667 0 0 0 60.330666 0l301.653334-301.696a42.666667 42.666667 0 1 0-60.288-60.330667l-271.530667 271.488z" fill="#52C41A" p-id="2696"></path></svg></div><div class="notification__text"><div class="notification__text-title">
   扒取成功</div><div class="notification__text-subtitle">您可以下载该资源！</div></div></div><div class="notification__btns"><button class="notification__btn" type="button" data-dismiss="note-43044f05"><span class="notification__btn-text">OK</span></button></div></div></div>';
    // exit;
}else{
    // 扒站接口
    $api_url = 'https://bz.v.api.aa1.cn/index.php?url='.$url2.'';
    $data = file_get_contents($api_url);
    $arr = json_decode($data, true);    // 将获取到的 JSON 数据解析成数组
    $downloadurl = $arr['downloadurl']; // 下载地址
    $msg = $arr['msg']; // 扒取结果
}
// 获取网站标题接口
$api_url_title = 'https://bz.v.api.aa1.cn/web-head.php?url='.$url2.'&type=title';
$api_url_keywords = 'https://bz.v.api.aa1.cn/web-head.php?url='.$url2.'&type=keywords';
$api_url_description = 'https://bz.v.api.aa1.cn/web-head.php?url='.$url2.'&type=description';
$site_title = file_get_contents($api_url_title); // 标题获取
$site_keywords = file_get_contents($api_url_keywords); // 关键字获取
$site_description = file_get_contents($api_url_description); // 网站描述获取
require __DIR__.'/header.html';
if($site_title == ''){
header("Location: ../index.php"); 
// exit;//防止下方的代码执行，中断执行
}
set_time_limit(2800);

?>

<body>
    <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    <div id="preloader" class="preloader">
        <div class="inner">
            <div class="line1"></div>
            <div class="line2"></div>
            <div class="line3"></div>
        </div>
    </div>
    <section class="fxt-template-animation fxt-template-layout34" data-bg-image="img/elements/bg1.png">
        <div class="fxt-shape">
            <div class="fxt-transformX-L-50 fxt-transition-delay-1">
                <img src="img/shape1.png" alt="Shape">
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-lg-8">
                    <div class="fxt-column-wrap justify-content-between">
                        <div class="fxt-animated-img">
                            <div class="fxt-transformX-L-50 fxt-transition-delay-10">
                                <img src="img/bg34-1.png" alt="Animated Image">
                            </div>
                        </div>
                        <div class="fxt-transformX-L-50 fxt-transition-delay-3">
                            <a href="../index.php" class="fxt-logo"><img src="img/logo-top.png" alt="Logo"></a>
                        </div>
                        
                        <div class="fxt-transformX-L-50 fxt-transition-delay-5">
                            <div class="fxt-middle-content">
                                <h2 class="fxt-main-title">爬取结果<span class="tk-tag tk-tag-red"><?php if($msg =='已扒取成功'){echo '成功';}else {echo 'Error 失败';} ?></span></h2>
                                <p>标题：</p>
                                <pre><span id="text" data-text='["<?php echo $site_title; ?>"]'></span>...</pre>
                                <p>关键字：</p>
                                <pre><span><?php echo $site_keywords; ?></span>...</pre>
                                <p>站点描述：</p>
                                <pre><span ><?php echo $site_description; ?></span>...</pre>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-4">
                    <div class="fxt-column-wrap justify-content-center">
                        <div class="fxt-form">
                            <!-- 扒站表单 -->
                            <h2 class="fxt-main-title">Zip DownLoad.</h2>
                            <p>我承诺扒取的资源不做任何商业及违法用途！</p>
                            <form style="text-align:center" action="bz.php" method="POST">
                                <div class="form-group">
                                  
                                </div>
                                <div class="form-group">
                                    <button class="fxt-btn-fill" onclick="window.open('<?php echo $downloadurl;?>')">下载资源</button>
                                </div>
                            </form>
                        </div>
<?php require __DIR__.'/footer.html'; ?>